﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MpSoft.Library.DAO.Products;
using MpSoft.Library.DTO;
using MpSoft.Basic.Configuration;

namespace MpSoft.Library.BUSS.Products
{
    #region  Manufacturer

    public class ManufacturerBUSS
    {
        private const string manufacturer_ALL_KEY = "Mp.manufacturer.all-{0}";
        private const string manufacturer_BY_ID_KEY = "Mp.manufacturer.id-{0}";

        private static void ManufacturerRemoveCache()
        {
            MpCache.RemoveByPattern(manufacturer_ALL_KEY);
            MpCache.RemoveByPattern(manufacturer_BY_ID_KEY);
        }

        public static int Manufacturer_Add(Manufacturer obj)
        {
            var result = ManufacturerDAO.Manufacturer_Add(obj);
            return result;
        }
        public static int Manufacturer_Update(Manufacturer obj)
        {
            var result = ManufacturerDAO.Manufacturer_Update(obj);
            return result;
        }

        public static int Manufacturer_Delete(int ManufacturerID)
        {
            var result = ManufacturerDAO.Manufacturer_Delete(ManufacturerID);
            return result;
        }

        public static Manufacturer Manufacturer_ByID(int ManufacturerID)
        {
            var list = Manufacturer_Select(ManufacturerID, false, 0);
            if (list != null)
                return list.FirstOrDefault();
            return null;
        }

        public static List<Manufacturer> Manufacturer_Select(int ManufacturerID, bool IsActive, int SortOrder)
        {
            return ManufacturerDAO.Manufacturer_Select(ManufacturerID, IsActive, SortOrder);
        }

    }

    #endregion
}
